from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject

class MyObject(QObject):
    # a. 定义一个自定义信号
    my_signal = pyqtSignal(str)

    # b. 定义一个槽函数
    @pyqtSlot(str)
    def my_slot(self, message):
        print("Received message: ", message)

# 创建一个对象
obj = MyObject()

# c. 连接信号和槽 
obj.my_signal.connect(obj.my_slot)

# d. 触发信号
obj.my_signal.emit("Hello, World!")